package com.example.myapplication.frament;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.myapplication.R;
import com.example.myapplication.frament.dynasty.HanZiToPinYin;

public class FushiFragment extends androidx.fragment.app.Fragment {
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(getContext() , R.layout.fushi , null);
        WebView web=view.findViewById(R.id.web);
        web.setWebViewClient(new WebViewClient());
        web.getSettings().setBuiltInZoomControls(true);
//        Button button=getActivity().findViewById(R.id.btn);
        EditText et=getActivity().findViewById(R.id.et);
//        button.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
                web.loadUrl("http://minzu.folkw.com/GaiLan_list.Asp?GaiLan=fushi&MinZu="+ HanZiToPinYin.getAllPinyin(et.getText().toString()));
//            }
//        });
//        et.setOnKeyListener(new View.OnKeyListener() {
//            @Override
//            public boolean onKey(View v, int keyCode, KeyEvent event) {
//                //手机上的回车进行操作
//                if (keyCode==KeyEvent.ACTION_DOWN||keyCode==KeyEvent.KEYCODE_ENTER&&event.getAction()==KeyEvent.ACTION_DOWN){
//                    System.out.println("kaixing");
//                    web.loadUrl("http://minzu.folkw.com/GaiLan_list.Asp?GaiLan=fushi&MinZu="+et.getText());
//                }
//
//                return false;
//            }
//        });
        return view;
    }
}
